<template>
  <div>
    <basicTableComponents :columns="columns" :data="tableData" @rowClick="rowClick">
        <template #tooltip="{ row }">
            <el-tooltip :content="row.name" placement="top">
                {{ row.name }}
            </el-tooltip>
        </template>
    </basicTableComponents>
  </div>
</template>

<script setup lang="ts">
import { ref, defineProps, defineEmits, watch } from 'vue';
import basicTableComponents from '../components/basicTableComponents.vue';
import { currentGET } from "@/api";
import { PopupType } from '../../index.d'
import { inject } from 'vue'
const showPopup = inject('showPopup') as (data: PopupType) => void;

const props = defineProps({
    params: {
        type: Object,
        required: false
    },
});
const tableData = ref([]);
const getData = (params: Object) => {
  console.log(params, 'params');
  currentGET("knowledgeList", params).then((res) => {
    if (res.success) {
      tableData.value = res.data.list;
    }
  });
};
watch(() => props.params, (newVal: Object) => {
    getData(newVal);
}, { immediate: true })
const emit = defineEmits(['rowClick'])
const rowClick = (item: Object)=> {
    // showPopup({ type: 42, show: true, popupFlag: 'knowledgeView', searchInfo: {id: item.row.id}})
    emit('rowClick', item)
}


const columns = [
  {
    prop: 'name',
    label: '名称',
    // width: '120'
  },
  {
      prop: 'type',
      label: '类型',
      width: '150'
  },
]
</script>

<style scoped>
/* 在这里编写组件样式 */
</style>
